package com.example.reggie.config;

import com.example.reggie.common.JacksonObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;

@Slf4j
@Configuration
public class WebConfigurer implements WebMvcConfigurer {

    //注入
//    @Autowired
//    LoginCheckInterceptor interceptor;
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        // add:增加拦截的路径 exclude:除这些路径之外
//        registry.addInterceptor(interceptor).addPathPatterns("/**").excludePathPatterns("/employee/login", "employee/logout"
//                ,"/backend/**","/front/**");
//    }

    //消息转换器
    @Override
    public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
        MappingJackson2HttpMessageConverter converter=new MappingJackson2HttpMessageConverter();
        converter.setObjectMapper(new JacksonObjectMapper());
        converters.add(0,converter);
    }

}
